home *** CD-ROM | disk | FTP | other *** search
/ Acorn User: China / Acorn User China CD-ROM (UK) (Disc B) / Acorn User China CD-ROM (UK) (Disc B).bin / STUTTGART / FROMUTS / UNIXLIB37B / src_c_math < prev    next >
Encoding:
C/C++ Source or Header  |  1991-01-21  |  1.1 KB  |  73 lines

  1. #ifdef __STDC__
  2. static char sccs_id[] = "@(#) math.c 1.0 "__DATE__" HJR";
  3. #else
  4. static char sccs_id[] = "@(#) math.c 1.0 26/9/90 HJR";
  5. #endif
  6.  
  7. /* math.c (c) Copyright 1990 H.Rogers */
  8.  
  9. #include <math.h>
  10.  
  11. #ifdef __STDC__
  12. double cosh(register double x)
  13. #else
  14. double cosh(x)
  15. register double x;
  16. #endif
  17. {
  18. return((exp(x) + exp(-x))/2);
  19. }
  20.  
  21. #ifdef __STDC__
  22. double sinh(register double x)
  23. #else
  24. double sinh(x)
  25. register double x;
  26. #endif
  27. {
  28. return((exp(x) - exp(-x))/2);
  29. }
  30.  
  31. #ifdef __STDC__
  32. double tanh(register double x)
  33. #else
  34. double tanh(x)
  35. register double x;
  36. #endif
  37. {
  38. register double x1,x2;
  39.  
  40. x1 = exp(x); x2 = exp(-x);
  41. return((x1 - x2)/(x1 + x2));
  42. }
  43.  
  44. #ifdef __STDC__
  45. double frexp(register double x,register int *p)
  46. #else
  47. double frexp(x,p)
  48. register double x;
  49. register int *p;
  50. #endif
  51. {
  52. register int e = 0;
  53.  
  54. if (x != 0)
  55.   {
  56.   while (x < 0.5) { x *= 2; e--; }
  57.   while (x >= 1) { x /= 2; e++; }
  58.   }
  59.  
  60. *p = e; return(x);
  61. }
  62.  
  63. #ifdef __STDC__
  64. double ldexp(register double x,register int y)
  65. #else
  66. double ldexp(x,y)
  67. register double x;
  68. register int y;
  69. #endif
  70. {
  71. return(x * pow((double)2,(double)y));
  72. }
  73.